<style lang="scss" scoped>
	.goto-share {

		// 点击分享按钮
		.share-img {
			width: 50upx;
			height: 50upx;
			padding: 20upx;
			border-radius: 50%;
			box-shadow: 0 0 5px 0 rgb(66, 66, 66);
			background-color: #3c3f86;
			position: fixed;
			bottom: 20upx;
			// #ifdef H5
			bottom: 120upx;
			// #endif
			right: 40upx;
			z-index: 9;
		}
	}
</style>
<template>
	<view class="goto-share">
		<!-- 个人分享 选择器 -->
		<image class="share-img" src="../../static/carm.png" @tap.stop="showActionsheet()" mode="aspectFit"/>
	</view>
</template>

<script>
	import {
		$storage
	} from "@/utils";
	export default {
		data() {
			return {
				// 类型选择器相关参数配置
				itemList: []
			};
		},
		methods: {
			// 底部个人分享 弹窗相关操作
			async showActionsheet() {
				if (!this.vuex_user && !this.vuex_user.id) {
					uni.showToast({
						title: "请先登陆...",
						icon: "loading",
						duration: 1000,
					});
					return ;
				}
				let user = await this.$u.api.getCurrentUser();
				// 根据 用户角色 判断当前用户是否具有发布视频的权利？或者说什么都没有发布的权利？或者只有发布照片的权利？
				if(!!user.is_vedio && user.is_vedio == 1){
					this.itemList = ["照片", "视频"];
				}else{
					this.itemList = ["照片"];
				}
				uni.showActionSheet({
					itemList: this.itemList,
					success: function(res) {
						if (res.tapIndex == 0) {
							uni.navigateTo({
								url: "/pages/share?type=照片",
							});
						} else if (res.tapIndex == 1) {
							uni.navigateTo({
								url: "/pages/share?type=视频",
							});
						}
					},
					fail: function(res) {
						console.log(res.errMsg);
					},
				});
			},
		},
	};
</script>
